﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FBGraph.ClientGenerator.CodeGen;

namespace FBGraph.ClientGenerator.Tests.CodeGen
{
    [TestClass]
    public class ConstructorTests
    {
        [TestMethod]
        public void OutputNoParameters()
        {
            var type = new CodeGenType("TestType", "Test");
            var ctr = new Constructor(type)
            {
                Body = "// foo"
            };

            var expected =
@"public TestType()
{
    // foo
}
".ReplaceTabs();
            var actual = ctr.ToString();

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void OutputSingleParameter()
        {
            var type = new CodeGenType("TestType", "Test");
            var ctr = new Constructor(type, new Parameter("foo", typeof(String)))
            {
                Body = "// foo"
            };


            var expected =
@"public TestType(String foo)
{
    // foo
}
".ReplaceTabs();
            var actual = ctr.ToString();

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void OutputMultipleParameters()
        {
            var type = new CodeGenType("TestType", "Test");
            var ctr = new Constructor(type, new Parameter("foo", typeof(String)), new Parameter("bar", typeof(Int32)))
            {
                Body = "// foo",
            };


            var expected =
@"public TestType(String foo, Int32 bar)
{
    // foo
}
".ReplaceTabs();
            var actual = ctr.ToString();

            Assert.AreEqual(expected, actual);
        }
    }
}